//
//  File.swift
//  DemoUI
//
//  Created by 白瑾浩 on 2022/1/24.
//

import Foundation
func date(){
    
//    //当前时间
//    let date = Date()
//    let calendar = Calendar.current
//    let dateComponents = calendar.dateComponents(in: TimeZone.current, from: date)
//    //print("\(dateComponents.year!)-\(dateComponents.month!)-\(dateComponents.day!)")
//    //当前时间
//    mRecordView?.currentDate?.text = "%.2d月%.2d日".format(parameters: dateComponents.month!,dateComponents.day!)
//
//    
//    if SPUtils.getStringValue("date").isEmpty {
//        return
//    }
//    
//    
//    // 当前时间戳
//    let currentDate =  formatter.date(from: "\(dateComponents.year!)-\(dateComponents.month!)-\(dateComponents.day!)" )
//    
//    let timestamp = Int(currentDate!.timeIntervalSince1970)
//    
//    // 秒级时间戳
////       let timeStamp2 = Int(timestamp)
////        // 毫秒级时间戳
////        let timeStamp3 = CLongLong(round(timestamp*1000))
////        let time = Date().timeIntervalSince1970
////        print(time)      // 1586851311.174374
////        print(Int(time)) // 1586851311
////        print(CLongLong(round(time*1000))) // 1586851311174
//    print( timestamp )
//    
//    let inseminationDate =  formatter.date(from: SPUtils.getStringValue("date") )
//    guard inseminationDate != nil else {
//        return
//    }
//    let inseminationTimestamp = Int(inseminationDate!.timeIntervalSince1970)
//    print( inseminationTimestamp )
//    
//    //计算孕周
//    let timestampDiff = timestamp - inseminationTimestamp
//    let weekTimestamp = 1 * 7 * 24 * 3600
//    
//    let week = timestampDiff/weekTimestamp
//    let day = (timestampDiff%weekTimestamp)/(24 * 3600)
//    
//    print( timestampDiff%weekTimestamp )
//    
//    print( day )
//    
//    mRecordView?.babyWeek?.text = "孕   周：%d周%d天".format(parameters: week,day)
//    
//    //计算预产期
//    let duedateTimeStamp =  inseminationTimestamp + 40 * 7 * 24 * 3600
//    
//    
//    let duedateStr = DateUtils.timeIntervalChangeToTimeStr(timeInterval: Double(duedateTimeStamp), "yyyy年MM月dd日")
//    print( duedateStr )
//    
//    mRecordView?.babyDueDate?.text = "预产期：\(duedateStr)"
//    
//    //计算出生时间还剩下多少天
//    let dayTimeStamp = duedateTimeStamp-timestamp
//    
//    mRecordView?.babyBirthDate?.text = "距离宝贝出生还有\(dayTimeStamp/(1*24*3600))天"
//    

}
